<style>
    .liveWidget{

        padding:2px 5px;
        cursor:default;


        /* CSS3 rules for rounded corners, box and text shadows: */

        -moz-border-radius:6px;
        -webkit-border-radius:6px;
        border-radius:6px;
        -moz-box-shadow:0 0 3px #CCCCCC;
        -webkit-box-shadow:0 0 3px #CCCCCC;
        box-shadow:0 0 3px #CCCCCC;
        text-shadow:0 2px 0 white;
        
        margin: 5px;
        position: absolute;
        left: 50%;
        margin-left: -35px;
    }


    .count{
        float:left;
        font-size:1.2em;
        font-weight:bold;
        text-align:center;
    }

    .onlinelabel{
        float:left;
        font-size:0.9em;
        padding:0 4px;
        text-transform:uppercase;
    }
</style>
<?php
/////Intstruction///////////////
//1- install Piwik on your sevrer
//2- fill in data below
//3 -call this file like this on the pages you want, where you want it to appear via php include 
////////////////////////////////////////////////////////////////////////////////////SETTINGS/////////////////////////////////////////////////////////////////////////////////
//fill in below info from your piwik install

$token = '0c7085f8b61597076dcd2a7cc685b520';
$piwikpath = 'http://10.111.20.23/analytics';
$siteid = '2';

/////////////////////////////////////////////////////////////////////////////END OF SETTINGS///////////////////////////////////////////////////////////////////////////////////////



$token_auth = $token; //This token is used to authenticate your API request. Grab your token from the API page inside your Piwik interface or use 'anonymous'
$url = $piwikpath; //root to your install
$url .= "?module=API&method=Live.getCounters"; //asking for live stats
$url .= "&idSite=" . $siteid . "&lastMinutes=5"; // which site, default is 1, and how many visitors in last 30 Minutes
$url .= "&format=PHP";
$url .= "&token_auth=$token_auth";
$fetched = file_get_contents($url);
$content = unserialize($fetched);
// case error
if (!$content) {
    print("Error, content fetched = " . $fetched);
}

foreach ($content as $row) {

    $hits = $row['visits'];


    echo "<div class='liveWidget panel-header'>
      <div class='count panel-title'><b>$hits</b></div>
      <div class='onlinelabel panel-title'>online</div>
      </div>";
}
?>
